<?php

namespace App\Console\Commands;

use App\Models\FinishProduct;
use App\Models\Order;
use App\Models\OrderChild;
use App\Models\OrderSecond;
use App\Models\SemiFinishProduct;
use Illuminate\Console\Command;

class UpdateOrderData extends Command
{
    /**
     * 修复订单数据
     * php artisan command:updateorderdata
     *
     * @var string
     */
    protected $signature = 'command:updateorderdata';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        $order_id_arr = Order::where('is_del',1)->pluck('id')->toArray();
        OrderSecond::whereIn('order_id',$order_id_arr)->update(['is_del'=>2]);
        OrderChild::whereIn('order_id',$order_id_arr)->update(['is_del'=>2]);
        SemiFinishProduct::whereIn('order_id',$order_id_arr)->update(['is_del'=>2]);
        FinishProduct::whereIn('order_id',$order_id_arr)->update(['is_del'=>2]);
    }
}
